//
//  FTBLSwitchViewCell.m
//  FaceTo
//
//  Created by 姚冬元 on 2017/7/30.
//  Copyright © 2017年 chengbangming. All rights reserved.
//

#import "FTBLSwitchViewCell.h"

@implementation FTBLSwitchViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)initUI
{
    CGFloat fontSize = iphone6p ? 15 : 14;
    
    _titlelab = [[UILabel alloc] init];
    _titlelab.textColor = FontColor;
    _titlelab.textAlignment = NSTextAlignmentLeft;
    _titlelab.font = LPFont(fontSize);
    [_titlelab sizeToFit];
    [self addSubview:_titlelab];
    
    _switchBtn = [[UISwitch alloc] init];
    _switchBtn.on = NO;
    _switchBtn.onTintColor = FTColor;
//    _switchBtn.transform = CGAffineTransformMakeScale(0.75, 0.75);
    [_switchBtn addTarget:self action:@selector(switchAction) forControlEvents:UIControlEventValueChanged];
    
    self.accessoryView = _switchBtn;
    
    [_titlelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.left.offset(20);
    }];
}


- (void)switchAction {
    
    if (self.block) {
        
        self.block(_switchBtn.on, _row);
    }
}
@end
